// codegen.js
import { getAdapter } from "./language-adapters/index.js";

export function generateCode(ast, language = 'cpp') {
  const adapter = getAdapter(language);
  let codeLines = Array.isArray(ast) ? ast.flatMap(node => adapter.transform(node).split('\n')) : adapter.transform(ast).split('\n');
  
  return `${adapter.getHeader()}
${adapter.getMainTemplate(codeLines)}`;
}